/**
 * 用户处理通用处理js
 */
import request from "@/utils/request";
import { loginForm, loginSuccessType } from "./type";

enum API {
  USER_LOGIN_IN_URL = "/usercenter/admin/login",
  USERINFO_URL = "/usercenter/admin/getUserInfo",
  USER_LOGIN_OUT_URL = "",
}

export const reqUserLogin = (data: loginForm) =>
  request.post<loginSuccessType, any>(API.USER_LOGIN_IN_URL, data, {
    headers: {
      /**
       * 用来对应传値方式   表示表单传値  对应springboot @RequestParam
       * 'Content-Type':'application/x-www-form-urlencoded'
       *
       * 用来对象传値   对应springboot @RequestBody
       * 'content-type':"application/json"
       *
       * 请根据后台接値方式来自行定义
       */
      "Content-Type": "application/x-www-form-urlencoded",
    },
    timeout: 5000, // 设置请求超时时间为 5 秒
  });

export const reqUserInfo = () => request.post<any, any>(API.USERINFO_URL);

export const reqUserLogout = () =>
  request.post<any, any>(API.USER_LOGIN_OUT_URL);
